import pymysql
import hashlib

def get_md5(text):
    # 创建MD5对象
    md5 = hashlib.md5()
    
    # 更新要加密的文本
    md5.update(text.encode('utf-8'))
    
    # 获取加密后的结果（16进制表示）
    result = md5.hexdigest()
    
    return result

def insert_pw(i):
    id=i
    pw=get_md5(i)
    print(pw)
    sql=f"insert into password values( '{id}' , '{pw}' )"
    cur.execute(sql)

connection = pymysql.connect(host='127.0.0.1', user='root', password='777271ll',db='schooldata')
cur=connection.cursor()
for i in range(1001,1031):
    insert_pw(str(i))
for i in range(1101,1151):
    insert_pw(str(i))
insert_pw('0000')
connection.commit()
connection.close()